
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module gummworld2.toolkit</title>
</head><body bgcolor="#f0f0f8">

<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="gummworld2.html"><font color="#ffffff">gummworld2</font></a>.toolkit</strong></big></big> (version $Id: toolkit.py 305 2011-05-21 21:59:02Z stabbingfinger@gmail.com $)</font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:///C:/cygwin/home/bw/devel/python/svn/gummworld2/gamelib/gummworld2/toolkit.py">c:\cygwin\home\bw\devel\python\svn\gummworld2\gamelib\gummworld2\toolkit.py</a></font></td></tr></table>
    <p><tt>toolkit.py&nbsp;-&nbsp;Some&nbsp;helper&nbsp;tools&nbsp;for&nbsp;Gummworld2.</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
    
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="gummworld2.data.html">gummworld2.data</a><br>
<a href="os.html">os</a><br>
</td><td width="25%" valign=top><a href="pygame.html">pygame</a><br>
<a href="re.html">re</a><br>
</td><td width="25%" valign=top><a href="urllib.html">urllib</a><br>
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
    
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="gummworld2.toolkit.html#Struct">Struct</a>
</font></dt><dt><font face="helvetica, arial"><a href="gummworld2.toolkit.html#Tilesheet">Tilesheet</a>
</font></dt></dl>
</dd>
</dl>
 <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="Struct">class <strong>Struct</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
    
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>A&nbsp;class&nbsp;with&nbsp;arbitrary&nbsp;members.&nbsp;Construct&nbsp;it&nbsp;like&nbsp;a&nbsp;dict,&nbsp;then&nbsp;access&nbsp;the<br>
keys&nbsp;as&nbsp;instance&nbsp;attributes.<br>
&nbsp;<br>
s&nbsp;=&nbsp;<a href="#Struct">Struct</a>(x=2,&nbsp;y=4)<br>
print&nbsp;s.x,s.y<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="Struct-__init__"><strong>__init__</strong></a>(self, **kwargs)</dt></dl>

<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="Tilesheet">class <strong>Tilesheet</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
    
<tr><td bgcolor="#ffc8d8"><tt>&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="Tilesheet-__init__"><strong>__init__</strong></a>(self, file_path, image, margin, tile_size, spacing, rects)</dt></dl>

<dl><dt><a name="Tilesheet-get_image"><strong>get_image</strong></a>(self, tile_id)</dt></dl>

<dl><dt><a name="Tilesheet-tile_info"><strong>tile_info</strong></a>(self, tile_id)</dt><dd><tt>Return&nbsp;a&nbsp;<a href="#Struct">Struct</a>&nbsp;populated&nbsp;with&nbsp;tilesheet&nbsp;info&nbsp;for&nbsp;tile_id.&nbsp;This&nbsp;info<br>
represents&nbsp;everything&nbsp;needed&nbsp;by&nbsp;the&nbsp;Tile&nbsp;class&nbsp;constructor&nbsp;in<br>
world_editor.py.<br>
&nbsp;<br>
<a href="#Struct">Struct</a>&nbsp;members:<br>
&nbsp;&nbsp;&nbsp;&nbsp;name&nbsp;:&nbsp;str;&nbsp;relative&nbsp;path&nbsp;to&nbsp;image&nbsp;file<br>
&nbsp;&nbsp;&nbsp;&nbsp;image&nbsp;:&nbsp;pygame.surface.Surface;&nbsp;the&nbsp;loaded&nbsp;image<br>
&nbsp;&nbsp;&nbsp;&nbsp;margin&nbsp;:&nbsp;Vec2d;&nbsp;size&nbsp;of&nbsp;image's&nbsp;edge&nbsp;border<br>
&nbsp;&nbsp;&nbsp;&nbsp;size&nbsp;:&nbsp;Vec2d;&nbsp;size&nbsp;of&nbsp;a&nbsp;single&nbsp;tile<br>
&nbsp;&nbsp;&nbsp;&nbsp;spacing&nbsp;:&nbsp;Vec2d;&nbsp;spacing&nbsp;between&nbsp;tiles<br>
&nbsp;&nbsp;&nbsp;&nbsp;rects&nbsp;:&nbsp;pygame.Rect;&nbsp;list&nbsp;of&nbsp;rects&nbsp;defining&nbsp;tile&nbsp;subsurfaces</tt></dd></dl>

<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
    
<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl><dt><a name="-X_draw_parallax_tiles"><strong>X_draw_parallax_tiles</strong></a>(layer, tiles, pax_rect, view<font color="#909090">=None</font>)</dt><dd><tt>##&nbsp;EXPERIMENTAL:&nbsp;not&nbsp;working&nbsp;quite&nbsp;right</tt></dd></dl>
 <dl><dt><a name="-collapse_map"><strong>collapse_map</strong></a>(map, num_tiles<font color="#909090">=(2, 2)</font>, layers<font color="#909090">=None</font>)</dt><dd><tt>Collapse&nbsp;all&nbsp;layers&nbsp;in&nbsp;a&nbsp;map&nbsp;by&nbsp;combining&nbsp;num_tiles&nbsp;into&nbsp;one&nbsp;tile.<br>
Returns&nbsp;a&nbsp;new&nbsp;map.<br>
&nbsp;<br>
The&nbsp;map&nbsp;argument&nbsp;is&nbsp;the&nbsp;source&nbsp;map.&nbsp;It&nbsp;must&nbsp;be&nbsp;an&nbsp;instance&nbsp;of&nbsp;Map.<br>
&nbsp;<br>
The&nbsp;num_tiles&nbsp;argument&nbsp;is&nbsp;a&nbsp;tuple&nbsp;representing&nbsp;the&nbsp;number&nbsp;of&nbsp;tiles&nbsp;in&nbsp;the&nbsp;X<br>
and&nbsp;Y&nbsp;axes&nbsp;to&nbsp;combine.</tt></dd></dl>
 <dl><dt><a name="-collapse_map_layer"><strong>collapse_map_layer</strong></a>(map, layeri, num_tiles<font color="#909090">=(2, 2)</font>)</dt><dd><tt>Collapse&nbsp;a&nbsp;single&nbsp;layer&nbsp;in&nbsp;a&nbsp;map&nbsp;by&nbsp;combining&nbsp;num_tiles&nbsp;into&nbsp;one&nbsp;tile.<br>
&nbsp;<br>
The&nbsp;map&nbsp;argument&nbsp;is&nbsp;the&nbsp;source&nbsp;map.&nbsp;It&nbsp;must&nbsp;be&nbsp;an&nbsp;instance&nbsp;of&nbsp;Map.<br>
&nbsp;<br>
The&nbsp;layeri&nbsp;argument&nbsp;is&nbsp;an&nbsp;int&nbsp;representing&nbsp;the&nbsp;layer&nbsp;index&nbsp;to&nbsp;collapse.<br>
&nbsp;<br>
The&nbsp;num_tiles&nbsp;argument&nbsp;is&nbsp;a&nbsp;tuple&nbsp;representing&nbsp;the&nbsp;number&nbsp;of&nbsp;tiles&nbsp;in&nbsp;the&nbsp;X<br>
and&nbsp;Y&nbsp;axes&nbsp;to&nbsp;combine.</tt></dd></dl>
 <dl><dt><a name="-draw_grid"><strong>draw_grid</strong></a>(layer<font color="#909090">=0</font>)</dt><dd><tt>Draw&nbsp;grid&nbsp;if&nbsp;enabled.<br>
&nbsp;<br>
Grids&nbsp;for&nbsp;the&nbsp;specified&nbsp;layer&nbsp;are&nbsp;blitted&nbsp;to&nbsp;the&nbsp;camera&nbsp;surface.&nbsp;If&nbsp;the&nbsp;layer<br>
has&nbsp;been&nbsp;collapsed&nbsp;with&nbsp;the&nbsp;<a href="#-collapse_map_layer">collapse_map_layer</a>()&nbsp;function&nbsp;so&nbsp;that&nbsp;the<br>
layer's&nbsp;tile&nbsp;size&nbsp;differs&nbsp;from&nbsp;the&nbsp;grid&nbsp;line&nbsp;sprites,&nbsp;this&nbsp;will&nbsp;look&nbsp;weird.</tt></dd></dl>
 <dl><dt><a name="-draw_labels"><strong>draw_labels</strong></a>(layer<font color="#909090">=0</font>)</dt><dd><tt>Draw&nbsp;visible&nbsp;labels&nbsp;if&nbsp;enabled.<br>
&nbsp;<br>
Labels&nbsp;for&nbsp;the&nbsp;specified&nbsp;layer&nbsp;are&nbsp;blitted&nbsp;to&nbsp;the&nbsp;camera&nbsp;surface.&nbsp;If&nbsp;the<br>
layer&nbsp;has&nbsp;been&nbsp;collapsed&nbsp;with&nbsp;the&nbsp;<a href="#-collapse_map_layer">collapse_map_layer</a>()&nbsp;function&nbsp;so&nbsp;that<br>
the&nbsp;layer's&nbsp;tile&nbsp;size&nbsp;differs&nbsp;from&nbsp;the&nbsp;grid&nbsp;label&nbsp;sprites,&nbsp;this&nbsp;will&nbsp;look<br>
weird.</tt></dd></dl>
 <dl><dt><a name="-draw_parallax_tile_range"><strong>draw_parallax_tile_range</strong></a>(layer, tile_range, pax_rect)</dt><dd><tt>##&nbsp;EXPERIMENTAL:&nbsp;not&nbsp;working&nbsp;quite&nbsp;right</tt></dd></dl>
 <dl><dt><a name="-draw_parallax_tiles"><strong>draw_parallax_tiles</strong></a>(maps, view)</dt><dd><tt>maps&nbsp;is&nbsp;a&nbsp;list&nbsp;of&nbsp;maps<br>
&nbsp;<br>
Assumptions:<br>
&nbsp;&nbsp;&nbsp;&nbsp;1.&nbsp;Maps&nbsp;are&nbsp;in&nbsp;world&nbsp;coords.<br>
&nbsp;&nbsp;&nbsp;&nbsp;2.&nbsp;Each&nbsp;map&nbsp;has&nbsp;the&nbsp;same&nbsp;number&nbsp;of&nbsp;layers.<br>
&nbsp;&nbsp;&nbsp;&nbsp;3.&nbsp;Each&nbsp;map's&nbsp;corresponding&nbsp;layer&nbsp;has&nbsp;the&nbsp;same&nbsp;parallax&nbsp;value.<br>
&nbsp;&nbsp;&nbsp;&nbsp;4.&nbsp;Each&nbsp;map&nbsp;layer&nbsp;has&nbsp;a&nbsp;parallax&nbsp;attribute:&nbsp;tuple&nbsp;of&nbsp;length&nbsp;2.<br>
&nbsp;&nbsp;&nbsp;&nbsp;5.&nbsp;Each&nbsp;map&nbsp;layer&nbsp;has&nbsp;a&nbsp;tile_range&nbsp;attribute:&nbsp;range&nbsp;of&nbsp;visible&nbsp;tiles.</tt></dd></dl>
 <dl><dt><a name="-draw_parallax_tiles_of_layer"><strong>draw_parallax_tiles_of_layer</strong></a>(cam, map, layer, parallax<font color="#909090">=(1.0, 1.0)</font>)</dt><dd><tt>##&nbsp;EXPERIMENTAL:&nbsp;not&nbsp;working&nbsp;quite&nbsp;right</tt></dd></dl>
 <dl><dt><a name="-draw_sprite"><strong>draw_sprite</strong></a>(s, blit_flags<font color="#909090">=0</font>)</dt><dd><tt>Draw&nbsp;a&nbsp;sprite&nbsp;on&nbsp;the&nbsp;camera's&nbsp;surface&nbsp;using&nbsp;world-to-screen&nbsp;conversion.</tt></dd></dl>
 <dl><dt><a name="-draw_tiles"><strong>draw_tiles</strong></a>()</dt><dd><tt>Draw&nbsp;visible&nbsp;tiles.<br>
&nbsp;<br>
This&nbsp;function&nbsp;assumes&nbsp;that&nbsp;the&nbsp;tiles&nbsp;stored&nbsp;in&nbsp;the&nbsp;map&nbsp;are&nbsp;sprites.</tt></dd></dl>
 <dl><dt><a name="-draw_tiles_of_layer"><strong>draw_tiles_of_layer</strong></a>(layeri, pallax_factor_x<font color="#909090">=1.0</font>, pallax_factor_y<font color="#909090">=1.0</font>)</dt><dd><tt>Draw&nbsp;visible&nbsp;tiles.<br>
&nbsp;<br>
This&nbsp;function&nbsp;assumes&nbsp;that&nbsp;the&nbsp;tiles&nbsp;stored&nbsp;in&nbsp;the&nbsp;map&nbsp;are&nbsp;sprites.</tt></dd></dl>
 <dl><dt><a name="-export_world_quadtree"><strong>export_world_quadtree</strong></a>(fh, entities)</dt><dd><tt>A&nbsp;quadtree-to-text&nbsp;exporter.<br>
&nbsp;<br>
This&nbsp;function&nbsp;is&nbsp;required&nbsp;by&nbsp;world_editor.py,&nbsp;and&nbsp;possibly&nbsp;other&nbsp;scripts,&nbsp;to<br>
export&nbsp;quadtree&nbsp;entities&nbsp;to&nbsp;a&nbsp;text&nbsp;file.<br>
&nbsp;<br>
Geometry&nbsp;classes&nbsp;used&nbsp;by&nbsp;this&nbsp;plugin&nbsp;are:&nbsp;RectGeometry,&nbsp;CircleGeometry,&nbsp;and<br>
PolyGeometry.<br>
&nbsp;<br>
The&nbsp;values&nbsp;saved&nbsp;are&nbsp;those&nbsp;needed&nbsp;for&nbsp;each&nbsp;shape-class's&nbsp;constructor,&nbsp;plus&nbsp;a<br>
block&nbsp;of&nbsp;arbitrary&nbsp;user&nbsp;data.&nbsp;The&nbsp;user&nbsp;data&nbsp;is&nbsp;url-encoded.</tt></dd></dl>
 <dl><dt><a name="-get_parallax_tile_range"><strong>get_parallax_tile_range</strong></a>(cam, map, layer, parallax, orig<font color="#909090">='center'</font>)</dt><dd><tt>##&nbsp;EXPERIMENTAL:&nbsp;not&nbsp;working&nbsp;quite&nbsp;right<br>
#def&nbsp;<a href="#-get_parallax_tile_range">get_parallax_tile_range</a>(cam,&nbsp;map,&nbsp;layer,&nbsp;parallax,&nbsp;orig='bottomleft'):</tt></dd></dl>
 <dl><dt><a name="-get_tilesheet_info"><strong>get_tilesheet_info</strong></a>(tilesheet_path)</dt><dd><tt>Get&nbsp;the&nbsp;tilesheet&nbsp;meta&nbsp;data&nbsp;from&nbsp;file&nbsp;if&nbsp;it&nbsp;exists.</tt></dd></dl>
 <dl><dt><a name="-import_world_quadtree"><strong>import_world_quadtree</strong></a>(fh, rect_cls, poly_cls, circle_cls)</dt><dd><tt>A&nbsp;world&nbsp;entity&nbsp;importer&nbsp;compatible&nbsp;with&nbsp;QuadTree.<br>
&nbsp;<br>
This&nbsp;function&nbsp;is&nbsp;required&nbsp;by&nbsp;world_editor.py,&nbsp;and&nbsp;possibly&nbsp;other&nbsp;scripts,&nbsp;to<br>
import&nbsp;world&nbsp;entities&nbsp;from&nbsp;a&nbsp;text&nbsp;file.&nbsp;It&nbsp;understands&nbsp;the&nbsp;format&nbsp;of&nbsp;files<br>
created&nbsp;by&nbsp;<a href="#-export_world_quadtree">export_world_quadtree</a>().<br>
&nbsp;<br>
Geometry&nbsp;classes&nbsp;used&nbsp;by&nbsp;this&nbsp;function&nbsp;to&nbsp;create&nbsp;shape&nbsp;objects&nbsp;are&nbsp;specified<br>
by&nbsp;the&nbsp;rect_cls,&nbsp;poly_cls,&nbsp;and&nbsp;circle_cls&nbsp;arguments.&nbsp;The&nbsp;constructor<br>
parameters&nbsp;must&nbsp;have&nbsp;the&nbsp;same&nbsp;signature&nbsp;as&nbsp;geometry.RectGeometry,&nbsp;et&nbsp;al.<br>
&nbsp;<br>
The&nbsp;values&nbsp;imported&nbsp;are&nbsp;those&nbsp;needed&nbsp;for&nbsp;each&nbsp;shape-class's&nbsp;constructor,<br>
plus&nbsp;a&nbsp;block&nbsp;of&nbsp;arbitrary&nbsp;user&nbsp;data&nbsp;which&nbsp;will&nbsp;be&nbsp;placed&nbsp;in&nbsp;the&nbsp;shape<br>
instance's&nbsp;user_data&nbsp;attribute.<br>
&nbsp;<br>
The&nbsp;user_data&nbsp;is&nbsp;also&nbsp;parsed&nbsp;for&nbsp;tilesheet&nbsp;info.&nbsp;Tilesets&nbsp;are&nbsp;loaded&nbsp;and<br>
returned&nbsp;as&nbsp;a&nbsp;dict&nbsp;of&nbsp;toolkit.<a href="#Tilesheet">Tilesheet</a>,&nbsp;keyed&nbsp;by&nbsp;relative&nbsp;path&nbsp;to&nbsp;the<br>
image&nbsp;file.</tt></dd></dl>
 <dl><dt><a name="-interpolated_step"><strong>interpolated_step</strong></a>(pos, step, interp)</dt><dd><tt>Returns&nbsp;(float,float).<br>
&nbsp;<br>
This&nbsp;is&nbsp;a&nbsp;utility&nbsp;for&nbsp;drawing&nbsp;routines,&nbsp;after&nbsp;pos&nbsp;has&nbsp;been&nbsp;updated&nbsp;by&nbsp;step.<br>
For&nbsp;example:<br>
&nbsp;&nbsp;&nbsp;&nbsp;def&nbsp;update():<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;move_camera()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;State.camera.update()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sprite_group.update()&nbsp;&nbsp;#&nbsp;e.g.&nbsp;steps&nbsp;a&nbsp;sprite&nbsp;position<br>
&nbsp;&nbsp;&nbsp;&nbsp;def&nbsp;draw():<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;interp&nbsp;=&nbsp;State.camera.interpolate()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;camera_pos&nbsp;=&nbsp;State.camera.rect.topleft<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;s&nbsp;in&nbsp;sprite_group:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sprite_pos&nbsp;=&nbsp;Vec2d(s.rect.topleft)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pos&nbsp;=&nbsp;sprite_pos&nbsp;-&nbsp;camera_pos<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;step&nbsp;=&nbsp;s.step<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;interp_pos&nbsp;=&nbsp;toolkit.<a href="#-interpolated_step">interpolated_step</a>(pos,&nbsp;step,&nbsp;interp)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;surf.blit(s.image,&nbsp;interp_pos)</tt></dd></dl>
 <dl><dt><a name="-load_entities"><strong>load_entities</strong></a>(filepath, cls_dict<font color="#909090">={}</font>)</dt><dd><tt>Load&nbsp;entities&nbsp;via&nbsp;the&nbsp;import_world_quadtree&nbsp;plugin.&nbsp;Return&nbsp;a&nbsp;list&nbsp;of<br>
entities.<br>
&nbsp;<br>
The&nbsp;cls_dict&nbsp;argument&nbsp;is&nbsp;a&nbsp;dict&nbsp;of&nbsp;classes&nbsp;to&nbsp;construct&nbsp;when&nbsp;encountering<br>
shape&nbsp;data.&nbsp;The&nbsp;following&nbsp;keys&nbsp;are&nbsp;supported:&nbsp;'rect_cls',&nbsp;'poly_cls',<br>
'circle_cls'.&nbsp;If&nbsp;any&nbsp;of&nbsp;those&nbsp;keys&nbsp;are&nbsp;missing&nbsp;from&nbsp;cls_dict,&nbsp;the&nbsp;following<br>
classes&nbsp;will&nbsp;be&nbsp;used&nbsp;by&nbsp;default:&nbsp;geometry.RectGeometry,<br>
geometry.PolyGeometry,&nbsp;geometry.CircleGeometry.&nbsp;Classes&nbsp;substituted&nbsp;in&nbsp;this<br>
manner&nbsp;must&nbsp;have&nbsp;constructors&nbsp;that&nbsp;are&nbsp;compatible&nbsp;with&nbsp;the&nbsp;default&nbsp;classes.</tt></dd></dl>
 <dl><dt><a name="-load_tiled_tmx_map"><strong>load_tiled_tmx_map</strong></a>(map_file_name, load_invisible<font color="#909090">=False</font>, convert_alpha<font color="#909090">=False</font>)</dt><dd><tt>Load&nbsp;an&nbsp;orthogonal&nbsp;TMX&nbsp;map&nbsp;file&nbsp;that&nbsp;was&nbsp;created&nbsp;by&nbsp;the&nbsp;Tiled&nbsp;Map&nbsp;Editor.<br>
&nbsp;<br>
Note:&nbsp;convert_alpha&nbsp;is&nbsp;experimental.&nbsp;It&nbsp;can&nbsp;lower&nbsp;performance&nbsp;when&nbsp;used<br>
with&nbsp;some&nbsp;images.&nbsp;Do&nbsp;it&nbsp;only&nbsp;if&nbsp;there's&nbsp;a&nbsp;need.<br>
&nbsp;<br>
Thanks&nbsp;to&nbsp;DR0ID&nbsp;for&nbsp;his&nbsp;nice&nbsp;tiledtmxloader&nbsp;module:<br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.pygame.org/project-map+loader+for+%27tiled%27-1158-2951.html">http://www.pygame.org/project-map+loader+for+%27tiled%27-1158-2951.html</a><br>
&nbsp;<br>
And&nbsp;the&nbsp;creators&nbsp;of&nbsp;Tiled&nbsp;Map&nbsp;Editor:<br>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.mapeditor.org/">http://www.mapeditor.org/</a></tt></dd></dl>
 <dl><dt><a name="-load_tilesheet"><strong>load_tilesheet</strong></a>(file_path)</dt><dd><tt>Load&nbsp;a&nbsp;tilesheet.&nbsp;A&nbsp;toolkit.<a href="#Tilesheet">Tilesheet</a>&nbsp;containing&nbsp;tilesheet&nbsp;info&nbsp;is<br>
returned.<br>
&nbsp;<br>
The&nbsp;file_path&nbsp;argument&nbsp;is&nbsp;the&nbsp;path&nbsp;to&nbsp;the&nbsp;image&nbsp;file.&nbsp;If&nbsp;file_path&nbsp;is&nbsp;a<br>
relative&nbsp;path,&nbsp;it&nbsp;must&nbsp;exist&nbsp;relative&nbsp;to&nbsp;data.data_dir&nbsp;(see&nbsp;the<br>
gummworld2.data&nbsp;module).&nbsp;If&nbsp;file_path.tilesheet&nbsp;exists&nbsp;it&nbsp;will&nbsp;be&nbsp;used&nbsp;to<br>
size&nbsp;the&nbsp;tiles;&nbsp;otherwise&nbsp;the&nbsp;defaults&nbsp;(0,0,32,32,0,0)&nbsp;will&nbsp;be&nbsp;used.</tt></dd></dl>
 <dl><dt><a name="-make_hud"><strong>make_hud</strong></a>(caption<font color="#909090">=None</font>, visible<font color="#909090">=True</font>)</dt><dd><tt>Create&nbsp;a&nbsp;HUD&nbsp;with&nbsp;dynamic&nbsp;items.&nbsp;This&nbsp;creates&nbsp;a&nbsp;default&nbsp;hud&nbsp;to&nbsp;serve<br>
both&nbsp;as&nbsp;an&nbsp;example,&nbsp;and&nbsp;for&nbsp;an&nbsp;early&nbsp;design&nbsp;and&nbsp;debugging&nbsp;convenience.</tt></dd></dl>
 <dl><dt><a name="-make_tiles"><strong>make_tiles</strong></a>()</dt><dd><tt>Create&nbsp;tiles&nbsp;to&nbsp;fill&nbsp;the&nbsp;current&nbsp;map.&nbsp;This&nbsp;is&nbsp;a&nbsp;utility&nbsp;for&nbsp;easily&nbsp;making<br>
visible&nbsp;content&nbsp;to&nbsp;aid&nbsp;early&nbsp;game&nbsp;design&nbsp;or&nbsp;debugging.<br>
&nbsp;<br>
Tiles&nbsp;transition&nbsp;from&nbsp;top-left&nbsp;to&nbsp;bottom-right,&nbsp;red&nbsp;to&nbsp;blue.</tt></dd></dl>
 <dl><dt><a name="-make_tiles2"><strong>make_tiles2</strong></a>()</dt><dd><tt>Create&nbsp;tiles&nbsp;to&nbsp;fill&nbsp;the&nbsp;current&nbsp;map.&nbsp;This&nbsp;is&nbsp;a&nbsp;utility&nbsp;for&nbsp;easily&nbsp;making<br>
visible&nbsp;content&nbsp;to&nbsp;aid&nbsp;early&nbsp;game&nbsp;design&nbsp;or&nbsp;debugging.<br>
&nbsp;<br>
Tiles&nbsp;transition&nbsp;from&nbsp;top&nbsp;to&nbsp;bottom,&nbsp;light&nbsp;blue&nbsp;to&nbsp;brown.</tt></dd></dl>
 <dl><dt><a name="-put_tilesheet_info"><strong>put_tilesheet_info</strong></a>(tilesheet_path, tilesheet_values)</dt><dd><tt>Put&nbsp;the&nbsp;tilesheet&nbsp;meta&nbsp;data&nbsp;to&nbsp;file.</tt></dd></dl>
 <dl><dt><a name="-reduce_map_layers"><strong>reduce_map_layers</strong></a>(map, layersi)</dt><dd><tt>Reduce&nbsp;the&nbsp;number&nbsp;of&nbsp;layers&nbsp;in&nbsp;a&nbsp;map&nbsp;by&nbsp;blitting&nbsp;two&nbsp;or&nbsp;more&nbsp;layers&nbsp;into<br>
a&nbsp;single&nbsp;layer.&nbsp;A&nbsp;new&nbsp;instance&nbsp;of&nbsp;Map&nbsp;is&nbsp;returned.<br>
&nbsp;<br>
The&nbsp;map&nbsp;argument&nbsp;is&nbsp;the&nbsp;source&nbsp;map.&nbsp;It&nbsp;must&nbsp;be&nbsp;an&nbsp;instance&nbsp;of&nbsp;Map.<br>
&nbsp;<br>
The&nbsp;layersi&nbsp;argument&nbsp;is&nbsp;a&nbsp;sequence&nbsp;of&nbsp;int&nbsp;of&nbsp;length&nbsp;two&nbsp;or&nbsp;more.&nbsp;The<br>
layers&nbsp;are&nbsp;blitted&nbsp;in&nbsp;the&nbsp;order&nbsp;specified.&nbsp;Layers&nbsp;not&nbsp;specified&nbsp;and&nbsp;layers<br>
that&nbsp;are&nbsp;not&nbsp;visible&nbsp;(i.e.&nbsp;layer.visible==False)&nbsp;will&nbsp;be&nbsp;copied&nbsp;as&nbsp;a&nbsp;layer<br>
instead&nbsp;of&nbsp;being&nbsp;blitted.<br>
&nbsp;<br>
Tiles&nbsp;in&nbsp;the&nbsp;blitted&nbsp;layers&nbsp;typically&nbsp;need&nbsp;to&nbsp;have&nbsp;some&nbsp;transparent&nbsp;pixels<br>
(e.g.&nbsp;a&nbsp;surface&nbsp;colorkey),&nbsp;otherwise&nbsp;their&nbsp;pixels&nbsp;would&nbsp;completely&nbsp;erase&nbsp;the<br>
tiles&nbsp;underneath.<br>
&nbsp;<br>
Alphas&nbsp;and&nbsp;blending&nbsp;are&nbsp;not&nbsp;supported&nbsp;by&nbsp;this&nbsp;routine.<br>
&nbsp;<br>
The&nbsp;tile&nbsp;and&nbsp;map&nbsp;sizes&nbsp;in&nbsp;the&nbsp;map&nbsp;layers&nbsp;should&nbsp;be&nbsp;of&nbsp;the&nbsp;same&nbsp;size.<br>
Otherwise&nbsp;the&nbsp;desired&nbsp;results&nbsp;will&nbsp;likely&nbsp;not&nbsp;be&nbsp;produced.&nbsp;If&nbsp;using<br>
collapse_map_layer&nbsp;and&nbsp;reduce_map_layers&nbsp;on&nbsp;subsets&nbsp;of&nbsp;map&nbsp;layers,&nbsp;one<br>
would&nbsp;usually&nbsp;want&nbsp;to&nbsp;call&nbsp;reduce_map_layers&nbsp;first.&nbsp;See&nbsp;the&nbsp;Combo&nbsp;example<br>
below,&nbsp;in&nbsp;which&nbsp;only&nbsp;two&nbsp;of&nbsp;three&nbsp;layers&nbsp;are&nbsp;transformed.<br>
&nbsp;<br>
Yes,&nbsp;this&nbsp;could&nbsp;be&nbsp;a&nbsp;challenge&nbsp;to&nbsp;manage&nbsp;for&nbsp;maps&nbsp;with&nbsp;special-purpose<br>
layers.&nbsp;One&nbsp;needs&nbsp;to&nbsp;know&nbsp;one's&nbsp;maps&nbsp;and&nbsp;layers&nbsp;before&nbsp;and&nbsp;after&nbsp;the<br>
transformations.&nbsp;Annotating&nbsp;map&nbsp;layers&nbsp;with&nbsp;a&nbsp;name&nbsp;or&nbsp;ID&nbsp;attribute&nbsp;might<br>
help.&nbsp;If&nbsp;the&nbsp;base&nbsp;layer&nbsp;has&nbsp;a&nbsp;name&nbsp;attribute&nbsp;it&nbsp;will&nbsp;be&nbsp;copied&nbsp;to&nbsp;the&nbsp;new<br>
map&nbsp;layer.<br>
&nbsp;<br>
Basic&nbsp;example:<br>
&nbsp;&nbsp;&nbsp;&nbsp;new_map&nbsp;=&nbsp;<a href="#-reduce_map_layers">reduce_map_layers</a>(orig_map,&nbsp;range(len(orig_map.layers)))<br>
&nbsp;<br>
Combo&nbsp;example:<br>
&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Reduce&nbsp;3-layer&nbsp;map&nbsp;to&nbsp;two&nbsp;layers.<br>
&nbsp;&nbsp;&nbsp;&nbsp;map&nbsp;=&nbsp;<a href="#-reduce_map_layers">reduce_map_layers</a>(map,&nbsp;(0,1))<br>
&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;Collapse&nbsp;layer&nbsp;0,&nbsp;two&nbsp;tiles&nbsp;into&nbsp;one&nbsp;tile.<br>
&nbsp;&nbsp;&nbsp;&nbsp;map&nbsp;=&nbsp;<a href="#-collapse_map_layer">collapse_map_layer</a>(map,&nbsp;0,&nbsp;(2,2))<br>
&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;The&nbsp;resulting&nbsp;map&nbsp;has&nbsp;two&nbsp;layers&nbsp;numbered&nbsp;0&nbsp;and&nbsp;1.</tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
    
<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><strong>BLEND_RGBA_ADD</strong> = 6<br>
<strong>IMAGE_FILE_EXTENSIONS</strong> = ('gif', 'png', 'jpg', 'jpeg', 'bmp', 'pcx', 'tga', 'tif', 'lbm', 'pbm', 'pgm', 'xpm')<br>
<strong>RLEACCEL</strong> = 16384<br>
<strong>SRCALPHA</strong> = 65536<br>
<strong>__author__</strong> = 'Gummbum, (c) 2011'<br>
<strong>__version__</strong> = '$Id: toolkit.py 305 2011-05-21 21:59:02Z stabbingfinger@gmail.com $'<br>
<strong>haspygame19</strong> = True<br>
<strong>hud_font</strong> = &lt;pygame.font.Font object&gt;</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#7799ee">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr>
    
<tr><td bgcolor="#7799ee"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%">Gummbum,&nbsp;(c)&nbsp;2011</td></tr></table>
</body></html>